package org.agile2soft.nexoma.core.entities;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
@SuppressWarnings({"serial"})
public class AuditId implements java.io.Serializable {

    private String serviceName;
    private Byte serviceId;
    private String userLogin;
    private String userName;
    private String documentNumber;
    private Date date;

    public String toString() {
        return String.format("%s,%s,%s,%s,%s,%s",serviceName,serviceId,userLogin,userName,documentNumber,date);
    }

    public AuditId() {
    }

    public AuditId(String serviceName, String userName,
            Date date) {
        this.serviceName = serviceName;
        this.userName = userName;
        this.date = date;
    }

    public AuditId(String serviceName, Byte serviceId,
            String userLogin, String userName,
            String documentNumber, Date date) {
        this.serviceName = serviceName;
        this.serviceId = serviceId;
        this.userLogin = userLogin;
        this.userName = userName;
        this.documentNumber = documentNumber;
        this.date = date;
    }

    @Column(name = "AUD_SERVICE_NAME", nullable = false, length = 100)
    public String getServiceName() {
        return this.serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    @Column(name = "AUD_SERVICE_ID")
    public Byte getServiceId() {
        return this.serviceId;
    }

    public void setServiceId(Byte serviceId) {
        this.serviceId = serviceId;
    }

    @Column(name = "AUD_USER_LOGIN", length = 15)
    public String getUserLogin() {
        return this.userLogin;
    }

    public void setUserLogin(String userLogin) {
        this.userLogin = userLogin;
    }

    @Column(name = "AUD_USER_NAME", nullable = false, length = 100)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "AUD_DOCUMENT_NUMBER", length = 25)
    public String getDocumentNumber() {
        return this.documentNumber;
    }

    public void setDocumentNumber(String documentNumber) {
        this.documentNumber = documentNumber;
    }

    @Column(name = "AUD_DATE", nullable = false, length = 19)
    public Date getDate() {
        return this.date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public boolean equals(Object other) {
        if ((this == other))
            return true;
        if ((other == null))
            return false;
        if (!(other instanceof AuditId))
            return false;
        AuditId castOther = (AuditId) other;

        return ((this.getServiceName() == castOther
                .getServiceName()) || (this.getServiceName() != null
                && castOther.getServiceName() != null && this
                .getServiceName()
                .equals(castOther.getServiceName())))
                && ((this.getServiceId() == castOther.getServiceId()) || (this
                        .getServiceId() != null
                        && castOther.getServiceId() != null && this
                        .getServiceId()
                        .equals(castOther.getServiceId())))
                && ((this.getUserLogin() == castOther
                        .getUserLogin()) || (this.getUserLogin() != null
                        && castOther.getUserLogin() != null && this
                        .getUserLogin().equals(
                                castOther.getUserLogin())))
                && ((this.getUserName() == castOther
                        .getUserName()) || (this.getUserName() != null
                        && castOther.getUserName() != null && this
                        .getUserName().equals(
                                castOther.getUserName())))
                && ((this.getDocumentNumber() == castOther
                        .getDocumentNumber()) || (this
                        .getDocumentNumber() != null
                        && castOther.getDocumentNumber() != null && this
                        .getDocumentNumber().equals(
                                castOther.getDocumentNumber())))
                && ((this.getDate() == castOther.getDate()) || (this
                        .getDate() != null
                        && castOther.getDate() != null && this
                        .getDate().equals(castOther.getDate())));
    }

    public int hashCode() {
        int result = 17;

        result = 37
                * result
                + (getServiceName() == null ? 0 : this
                        .getServiceName().hashCode());
        result = 37
                * result
                + (getServiceId() == null ? 0 : this.getServiceId()
                        .hashCode());
        result = 37
                * result
                + (getUserLogin() == null ? 0 : this.getUserLogin()
                        .hashCode());
        result = 37
                * result
                + (getUserName() == null ? 0 : this
                        .getUserName().hashCode());
        result = 37
                * result
                + (getDocumentNumber() == null ? 0 : this
                        .getDocumentNumber().hashCode());
        result = 37 * result
                + (getDate() == null ? 0 : this.getDate().hashCode());
        return result;
    }

}
